package com.google.enterprise.mailmigration;

import java.util.logging.Logger;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;

public class MigrationConfig {
    private static String gooAdminUser = null;
    private static String gooAdminPassword = null;
    private static String oldIMAPServer = null;
    private static String APPS_FEEDS_URL_BASE = null;
    private static String SERVICE_VERSION = null;
    private static String loginurl = null;
    
    private static final Logger logger = 
        Logger.getLogger(MigrationConfig.class.getName());

    public MigrationConfig() {
        try {
            this.loadConfiguration();
        } catch (ConfigurationException e) {
            logger.severe("ConfigurationException caught. " + e.getMessage());
        }
    }
    
    private void loadConfiguration() throws ConfigurationException {        
        XMLConfiguration config = new XMLConfiguration("migrationconfig.xml");
        this.setGooAdminUser(config.getProperty("gooadminuser").toString());
        logger.info(this.getGooAdminUser());
        this.setGooAdminPassword(config.getProperty("gooadminpwd").toString());
        logger.info(this.getGooAdminPassword());
        this.setOldIMAPServer(config.getProperty("imapserver").toString());
        logger.info(this.getOldIMAPServer());
        this.setAPPS_FEEDS_URL_BASE(config.getProperty("feedurl").toString());
        logger.info(this.getAPPS_FEEDS_URL_BASE());
        this.setSERVICE_VERSION(config.getProperty("serviceversion").toString());
        logger.info(this.getSERVICE_VERSION());
        this.setLoginurl(config.getProperty("loginurl").toString());
        logger.info(this.getLoginurl());
    }

    public static String getGooAdminUser() {
        return gooAdminUser;
    }

    public static void setGooAdminUser(String gooAdminUser) {
        MigrationConfig.gooAdminUser = gooAdminUser;
    }

    public static String getGooAdminPassword() {
        return gooAdminPassword;
    }

    public static void setGooAdminPassword(String gooAdminPassword) {
        MigrationConfig.gooAdminPassword = gooAdminPassword;
    }

    public static String getOldIMAPServer() {
        return oldIMAPServer;
    }

    public static void setOldIMAPServer(String oldIMAPServer) {
        MigrationConfig.oldIMAPServer = oldIMAPServer;
    }

    public static String getAPPS_FEEDS_URL_BASE() {
        return APPS_FEEDS_URL_BASE;
    }

    public static void setAPPS_FEEDS_URL_BASE(String APPS_FEEDS_URL_BASE) {
        MigrationConfig.APPS_FEEDS_URL_BASE = APPS_FEEDS_URL_BASE;
    }

    public static String getSERVICE_VERSION() {
        return SERVICE_VERSION;
    }

    public static void setSERVICE_VERSION(String SERVICE_VERSION) {
        MigrationConfig.SERVICE_VERSION = SERVICE_VERSION;
    }

    public static String getLoginurl() {
        return loginurl;
    }

    public static void setLoginurl(String loginurl) {
        MigrationConfig.loginurl = loginurl;
    }
}
